package com.eduran.test.model.logger;


import com.eduran.test.model.ConsoleWriter;
import com.eduran.test.model.LogWriter;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;

@Component
@Named("logger")
public class Logger_031 {
    private ConsoleWriter consoleWriter;
    private LogWriter fileWriter;

    @Inject
    public void setConsoleWriter(ConsoleWriter writer) {
        this.consoleWriter = writer;
    }

    @Inject
    public void setFileWriter(LogWriter fileWriter) {
        this.fileWriter = fileWriter;
    }

    public void writeFile(String text) {
        fileWriter.write(text);
    }
    public void writeConsole(String text) { if (consoleWriter != null) consoleWriter.write(text); }
    @PostConstruct
    public void init(){
        System.out.println("init");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("destroy");
    }
}
